<?php
  require '../../include/library.inc.php';
  require '../../include/admin_login.inc.php';
    
  $image_id = intval($_GET['image_id']);
  //$cat_id = intval($_GET['cat_id']);

  if($image_id) {
    $sql = "SELECT
			  file
			FROM
			  project_gallery
			WHERE
			  id = $image_id
              ";
    query($sql);
	$row = mysql_fetch_assoc(query($sql));
	$filename = $row['file'];
	
	$sql = "DELETE FROM 
               project_gallery
            WHERE
               id = $image_id
             ";
    query($sql);
	
	$sql = "DELETE FROM 
               project_gallery_description
            WHERE
               image_id = $image_id
             ";
    query($sql);
	
	unlink("../project_images/gallery/".$filename);
	unlink("../project_images/gallery/th_".$filename);
	
	$_SESSION['message'] = 'Снимка ID '.$image_id.' е изтрита успешно';
  }
  redirect($_SERVER['HTTP_REFERER']);
 /* if ($cat_id == 1) {
	  
	  redirect("images_gallery.php");
	  
  } elseif ($cat_id == 2) {
	  
	  redirect("images_pages.php");
	  
  } else {
	  
	  redirect("images_slideshow.php");
	  
  }
  */
  
?>